package com.prs.crm.action.document;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.document.DraftFlowType;
import com.prs.crm.service.document.DraftFlowTypeService;

public class DraftFlowTypeAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private DraftFlowType draftFlowType;
	private DraftFlowTypeService draftFlowTypeService;
	private Integer[] ids;
	private PaginationSupport pagination;
	
	public DraftFlowType getDraftFlowType() {
		return draftFlowType;
	}

	public void setDraftFlowType(DraftFlowType draftFlowType) {
		this.draftFlowType = draftFlowType;
	}

	public DraftFlowTypeService getDraftFlowTypeService() {
		return draftFlowTypeService;
	}

	public void setDraftFlowTypeService(
			DraftFlowTypeService draftFlowTypeService) {
		this.draftFlowTypeService = draftFlowTypeService;
	}

	public Integer[] getIds() {
		return ids;
	}

	public void setIds(Integer[] ids) {
		this.ids = ids;
	}

	public PaginationSupport getPagination() {
		return pagination;
	}

	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}

	@Action("listDraftFlowType")
	public String listDraftFlowType() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(
				DraftFlowType.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getDraftFlowTypeService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	@Action("editDraftFlowType")
	public String editDraftFlowType(){
		return SUCCESS;
	}
	
	@Action(value="saveDraftFlowType",results={
			@Result(name="success",type="redirect",location="listDraftFlowType"),
			@Result(name="error",type="chain",location="editDraftFlowType")
	})
	public String saveDraftFlowType(){
		this.getDraftFlowTypeService().save(draftFlowType);
		return SUCCESS;
	}
	@Action(value="removeDraftFlowType",results={
			@Result(name="success",type="redirect",location="listDraftFlowType"),
			@Result(name="error",type="chain",location="listDraftFlowType")
	})
	public String removeDraftFlowType(){
		if (ids==null) {
			this.setPrompt("请选择一行！");
		}
		this.getDraftFlowTypeService().batchRemove(ids);
		return SUCCESS;
	}
}
